#include<bits/stdc++.h>

using namespace std;
int n,sum,t;
bool vis[114514];
int oppo[114514];
int ljj[114514];
int check(int a,int cnt)
{
    vis[a]=1;
    for(int i=a-1;i>=1;i--)
    {
        if(vis[a]==vis[i]&&oppo[a]==oppo[i])
        return true;
    }
    return false;
}
int maxn=0;
void dfs(int now,int cu)
{
    if(now==n)
    {
        for(int i=1;i<=n;i++)
        {
            sum+=oppo[i];
            maxn=max(maxn,sum);
        }
    }
    sum=0;
    if(!check(now,1))
    {
        oppo[now]=0;
        dfs(now+1,1);
        dfs(now+1,0);
    }
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>oppo[i];
        }
        for(int i=1;i<=n;i++)
        {
            vis[i]=0;
            for(int j=1;j<=n;j++)
            {
                vis[j]=1;
            }
        }
        dfs(1,1);
        dfs(1,0);
        cout<<maxn<<"\n";
    }
    return 0;
}
